package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.ProductBean;
import com.project.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private IProductService productService;

    @RequestMapping("findByItem")
    public IPage<ProductBean> findByItem(Integer pageNo, String name, Integer startNum, Integer endNum, String isSellPrice, String type) {
        return productService.findByItem(pageNo, name, startNum, endNum, isSellPrice, type);
    }

    @RequestMapping("findById")
    public ProductBean findById(String id) {
//        System.out.println(id);
        return productService.findById(id);
//        return null;
    }


    @RequestMapping("update")
    public String updateSellPrice(String id, Integer price) {
        productService.update(id, price);
        return "ok";
    }
}
